home *** CD-ROM | disk | FTP | other *** search
- * Program..: Wordwrap.PRC
- * Author...: Tom Rettig
- * Date.....: January 3, 1985
- * Notes....: Two procedures for output of long character fields
- * with word wrapping at a specified column.
- * Note the use of .PRC for the extension of a
- * procedure file.
- * Input 'line' can be up to 254 chars.
- * 'max' is an integer for the maximum output string length.
- *
- PROCEDURE Wordwrap
- PARAMETERS line, max
- string = TRIM( line )
- ith = 1
- IF [] < string
- DO WHILE LEN(string) > max .AND. AT(" ",SUBSTR(string,ith)) > 0
- * Point to first space before column max...
- DO WHILE .T.
- * This construct was used because versions 1.0 and 1.1
- * do not support DO WHILE <condition> with a semicolon.
- * (See page D3-32 in the dBASE III Anomalies Section
- * in this issue of TechNotes.)
- IF ith-1 <= max .AND.;
- AT(" ",SUBSTR(string,ith)) > 0 .AND.;
- ith-1 + AT(" ",SUBSTR(string,ith)) <= max
- *
- ith = ith + AT(" ",SUBSTR(string,ith))
- ELSE
- EXIT
- ENDIF
- ENDDO
- * Output first part of string.
- DO Output WITH SUBSTR( string,1,ith-1 )
- * Truncate first part of string from string.
- IF ith < LEN( string )
- string = SUBSTR( string,ith )
- ith = 1
- ENDIF
- ENDDO
- ENDIF
- * Output last part of string.
- DO Output WITH string
- RETURN
- * EOP: Wordwrap
-
- PROCEDURE Output
- PARAMETERS string
- * A separate procedure is used for the output because
- * output occurs at two locations in the Wordwrap procedure.
- ? [ ] + string
- RETURN
- * EOP: Output
- * EOF: Wordwrap.PRC
-
-
- * Program..: Getty.PRG
- * Author...: Ray Love
- * Date.....: January 3, 1985
- * Notes....: Demonstrates Wordwrap.PRC by passing it the
- * Gettysburg address with a length parameter
- * determined by the user.
- SET TALK OFF
- SET PROCEDURE TO Wordwrap.PRC
- *
- * Initialize variables.
- getty = "Four score and seven years ago our fathers brought " +;
- "forth, upon this continent, a new nation, conceived " +;
- "in liberty, and dedicated to the proposition that " +;
- "all men are created equal."
- wrap = 0
- CLEAR
- * Get right margin of output.
- @ 1,1 SAY "Enter line length (15 - 65) ";
- GET wrap PICTURE "99" RANGE 15,65
- READ
- * Display right margin.
- @ 2,1 SAY SPACE( wrap ) + "*"
- * Call procedure and pass parameters.
- DO Wordwrap WITH getty, wrap
- CLOSE PROCEDURE
- SET TALK ON
- RETURN
- * EOF: Getty.PRG
-
-
-
-
-
-
-
-
-
-